{\rtf1\ansi\ansicpg936\cocoartf1138\cocoasubrtf230
{\fonttbl\f0\fmodern\fcharset0 Courier;}
{\colortbl;\red255\green255\blue255;\red0\green116\blue0;\red63\green110\blue116;\red38\green71\blue75;
\red92\green38\blue153;\red46\green13\blue110;\red28\green0\blue207;\red196\green26\blue22;\red170\green13\blue145;
}
\paperw11900\paperh16840\margl1440\margr1440\vieww19080\viewh7700\viewkind0
\deftab640
\pard\tx640\pardeftab640\pardirnatural

\f0\fs28 \AppleTypeServices\AppleTypeServicesF1441793 \cf2 \CocoaLigature0 //    // Start listening.\cf0 \
\cf2 //    [[SCListener sharedListener] listen];\cf0 \
\cf2 //    \cf0 \
\cf2 //    // Retrieve the average power.\cf0 \
\cf2 //    [[SCListener sharedListener] averagePower];\cf0 \
\cf2 //    \cf0 \
\cf2 //    // Retrieve the peak power.\cf0 \
\cf2 //    [[SCListener sharedListener] peakPower];\cf0 \
    \
    \cf2 // Hmm...we're using this guy a lot...\cf0 \
    \cf3 SCListener\cf0  *listener = [\cf3 SCListener\cf0  \cf4 sharedListener\cf0 ];\
    \
    \cf2 // We can temporarily stop returning levels\cf0 \
\cf2 //    [listener pause];\cf0 \
    [listener \cf4 listen\cf0 ]; \cf2 // Quick.\cf0 \
    \
    \
    \
    \cf2 // Or free up resources when we're not listening for awhile.\cf0 \
\cf2 //    [listener stop];\cf0 \
\cf2 //    [listener listen]; // Slower.\cf0 \
    \
    \cf2 // Advanced!:\cf0 \
    \cf2 //\cf0 \
    \cf2 // If you're using the average and the peak, fetch both at once.\cf0 \
\cf2 //    if (![listener isListening]) // If listener has paused or stopped...\cf0 \
\cf2 //        return;                    // ...bail.\cf0 \
\cf2 //    \cf0 \
\cf2 //    AudioQueueLevelMeterState *levels = [listener levels];\cf0 \
\cf2 //    Float32 peak = levels[0].mPeakPower;\cf0 \
\cf2 //    Float32 average = levels[0].mAveragePower;\cf0 \
\
    \
    \cf5 UIButton\cf0  *button = [\cf5 UIButton\cf0  \cf6 buttonWithType\cf0 :\cf6 UIButtonTypeCustom\cf0 ];\
    [button \cf6 setFrame\cf0 :\cf6 CGRectMake\cf0 (\cf7 100\cf0 , \cf7 100\cf0 , \cf7 100\cf0 , \cf7 40\cf0 )];\
    [button \cf6 setTitle\cf0 :\cf8 @"Tap"\cf0  \cf6 forState\cf0 :\cf6 UIControlStateNormal\cf0 ];\
    [button \cf6 addTarget\cf0 :\cf9 self\cf0  \cf6 action\cf0 :\cf9 @selector\cf0 (buttonHandle:) \cf6 forControlEvents\cf0 :\cf6 UIControlEventTouchUpInside\cf0 ];\
    [\cf9 self\cf0 .\cf5 view\cf0  \cf6 addSubview\cf0 :button];\
    \
    \cf3 timer\cf0  = [\cf5 NSTimer\cf0  \cf6 timerWithTimeInterval\cf0 :\cf7 1.0\cf0 /\cf7 60\cf0  \cf6 target\cf0 :\cf9 self\cf0  \cf6 selector\cf0 :\cf9 @selector\cf0 (buttonHandle:) \cf6 userInfo\cf0 :\cf9 nil\cf0  \cf6 repeats\cf0 :\cf9 YES\cf0 ];\
    \
    [[\cf5 NSRunLoop\cf0  \cf6 currentRunLoop\cf0 ] \cf6 addTimer\cf0 :\cf3 timer\cf0  \cf6 forMode\cf0 :\cf5 NSDefaultRunLoopMode\cf0 \
     ];\
\}\
\
- (\cf9 void\cf0 )buttonHandle:(\cf9 id\cf0 )sender\
\{\
    \cf5 CGFloat\cf0  ff = [[\cf3 SCListener\cf0  \cf4 sharedListener\cf0 ] \cf4 averagePower\cf0 ];\
    \
    \cf9 if\cf0 (ff > \cf7 0.5\cf0 )\
    \{\
        \cf6 NSLog\cf0 (\cf8 @"------------------------------================%f\\n"\cf0 , ff);\
    \}\
    \cf9 else\cf0 \
    \{\
        \cf6 NSLog\cf0 (\cf8 @"%f\\n"\cf0 , ff);\
    \}  \
\}}